From 79a18447fe70c67d682bcf585c2234efca25f46a Mon Sep 17 00:00:00 2001 From: "kfraser@localhost.localdomain" Date: Wed, 1 Aug 2007 19:17:08 +0100 Subject: [PATCH] xenstore: Do not assign to stdout/stderr/stdin - they are not implemented as variables on all systems. Signed-off-by: Keir Fraser --- tools/xenstore/utils.c | 7 +++---- tools/xenstore/utils.h | 2 +- tools/xenstore/xenstored_core.c | 6 +----- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/tools/xenstore/utils.c b/tools/xenstore/utils.c index d7f5219a87..a1ac12584a 100644 --- a/tools/xenstore/utils.c +++ b/tools/xenstore/utils.c @@ -10,19 +10,18 @@ #include #include "utils.h" -void xprintf(const char *fmt, ...) +static void default_xprintf(const char *fmt, ...) { va_list args; - if (!stderr) - return; /* could trace()? */ - va_start(args, fmt); vfprintf(stderr, fmt, args); va_end(args); fflush(stderr); } +void (*xprintf)(const char *fmt, ...) = default_xprintf; + void barf(const char *fmt, ...) { char *str; diff --git a/tools/xenstore/utils.h b/tools/xenstore/utils.h index ce14f3a408..f378343707 100644 --- a/tools/xenstore/utils.h +++ b/tools/xenstore/utils.h @@ -24,7 +24,7 @@ static inline bool strends(const char *a, const char *b) void barf(const char *fmt, ...) __attribute__((noreturn)); void barf_perror(const char *fmt, ...) __attribute__((noreturn)); -void xprintf(const char *fmt, ...); +void (*xprintf)(const char *fmt, ...); #define eprintf(_fmt, _args...) xprintf("[ERR] %s" _fmt, __FUNCTION__, ##_args) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index fc3171f14b..a969bcff56 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -1883,11 +1883,7 @@ int main(int argc, char *argv[]) close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); - - /* Get ourselves a nice xenstored crash if these are used. */ - stdin = NULL; - stdout = NULL; - stderr = NULL; + xprintf = trace; /* xprintf() must not use stderr */ } signal(SIGHUP, trigger_reopen_log); -- 2.30.2